//
//  UIViewController+ZMExtension.swift
//  ZMBaseModule
//
//  Created by Rowling on 2020/5/25.
//  Copyright © 2020 Rowling. All rights reserved.
//

import Foundation
import UIKit

extension UIViewController : ZMCompatible{}
extension ZM where Base : UIViewController {
    
    /// 设置导航栏样式
    func setbar(barTitColor : UIColor , titleFont : UIFont = UIFont.systemFont(ofSize: 18), titleColor : UIColor = UIColor.zm.color(hexString: "#333333")) {
        base.navigationController?.navigationBar.barTintColor = barTitColor
        base.navigationController?.navigationBar.titleTextAttributes = [
                  NSAttributedString.Key.foregroundColor : titleColor,
                  NSAttributedString.Key.font : titleFont
        ]
    }
    
    /// 隐藏导航栏下分割线
    func hideLine(hide : Bool) {
        if hide {
            base.navigationController?.navigationBar.shadowImage = UIImage()
        } else {
            base.navigationController?.navigationBar.shadowImage = nil
        }
    }
    
    /// 隐藏导航栏
    func hideNavBar(hide: Bool) {
        base.navigationController?.setNavigationBarHidden(hide, animated: false)
    }
    
    /// 导航栏背景色
    func navBackgroundColor(color: UIColor) {
        base.navigationController?.navigationBar.backgroundColor = color
    }

}
